package com.aifeng.hassan_food.sale

import android.os.Bundle
import com.aifeng.base.BaseActivity
import com.aifeng.common_ui.base.oneClick
import com.aifeng.common_ui.helper.ActivityStack
import com.aifeng.hassan_food.MainActivity
import com.aifeng.hassan_food.R
import com.aifeng.hassan_food.mine.OrderDetailActivity
import com.aifeng.utils.getExtra
import com.jeremyliao.liveeventbus.LiveEventBus
import kotlinx.android.synthetic.main.activity_confirm_done.*
import org.jetbrains.anko.startActivity

class ConfirmDoneActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_confirm_done)
        initTitle(title = "", divider = false)
    }

    override fun initTitle(title: String, name: String, divider: Boolean) {
        super.initTitle(title, name, divider)
        confirm_detail.oneClick {
            val orderIndex = intent.getExtra("orderIndex")
            if (orderIndex.isNotEmpty()) {
                ActivityStack.screenManager.popActivities(OrderDetailActivity::class.java)
            }
            startActivity<OrderDetailActivity>("id" to intent.getExtra("orderId"))
            ActivityStack.screenManager.popActivities(this::class.java)
        }

        confirm_home.oneClick {
            LiveEventBus.get("loginStatus").post("home")
            ActivityStack.screenManager.popAllActivityExcept(MainActivity::class.java)
        }
    }

}
